package com.huangwei.controller;

import com.huangwei.model.Car;
import com.huangwei.service.CarService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/carDetails")
public class CarDetailController {
    @Resource
    CarService carService;

    @GetMapping("/getCarDetails")
    public Car getCarDetails(HttpServletRequest request) {
        Map<String, String[]> map = request.getParameterMap();
        return carService.getOneCarById(Integer.parseInt(map.get("carId")[0]));
    }
}
